package com.yanqu.road.logic.sort;

import com.yanqu.road.entity.rank.xrank.XChannelRank;

import java.util.Comparator;

public class XChannelRankSort implements Comparator<XChannelRank> {

    @Override
    public int compare(XChannelRank o1, XChannelRank o2) {
        // 比较value
        int result = o2.getValue().compareTo(o1.getValue());
        if (result != 0) {
            return result;
        }
        // 比较时间
        long time = o1.getLastUpdateTime() - o2.getLastUpdateTime();
        result = time > 0 ? 1 : (time == 0 ? 0 : -1);
        return result;
    }
}
